package models

import (
	"github.com/goravel/framework/database/orm"
	"goravel/app/models/common"
)

// 客户报修表
type Repair struct {
	orm.Model
	OrderNo     string `gorm:"column:order_no" json:"order_no" form:"order_no"`
	Phone       string `gorm:"column:phone" json:"phone" form:"phone"`
	UserName    string `gorm:"column:user_name" json:"user_name" form:"user_name"`
	Way         int    `gorm:"column:way;comment:报修方式,1门店，2现场应急;default:1" json:"way" form:"way"`
	UserID      uint   `gorm:"column:user_id" json:"user_id" form:"user_id"`
	Description string `gorm:"column:description;comment:故障描述" json:"description" form:"description"`
	//车牌
	CarID       uint            `gorm:"column:car_id;comment:汽车编号" json:"car_id" form:"car_id"`
	Images      common.Album    `gorm:"column:images;" json:"images" form:"images"`
	Coordinates common.CoordRes `gorm:"column:coordinates;null;comment:坐标" form:"coordinates" json:"coordinates"`
	Address     string          `gorm:"column:address" json:"address" form:"address"`
	State       int             `gorm:"column:state;comment:'工单状态:正常工单：0未派单1已派单2双方签字3班长确认4完结，异常工单：1已派单2双方签字3班长确认4作业长签字5完结';default:0" json:"state" form:"state"`
	Ticket      *Ticket         `gorm:"foreignkey:RepairID" json:"ticket" form:"ticket"`
	Car         *Car            `gorm:"foreignkey:CarID" json:"car" form:"car"`
	Records     []Record        `gorm:"foreignkey:RepairID" json:"records" form:"records"`
	orm.SoftDeletes
}

func (Repair) TableName() string {
	return "repairs"
}
